<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>fetch 发送请求</title>
</head>

<body>
    <button>AJAX请求</button>
    <script>
        const btn = document.querySelector('button');
        btn.onclick = function() {
            //直接调用fetch函数
            // fetch('url',{可选配置对象})
            fetch('http://127.0.0.1:8000/fetch-server', {
                //method  请求方法
                method: 'POST',
                //请求体
                headers: {
                    name: 'ccj'
                },
                //请求体
                body: 'username=admin&password=admin'
            }).then(response => {
                console.log(response);
            })
        }
    </script>
</body>

</html>